import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore(
  'user',
  () => {
    const token = ref('') // 定义 token
    const empInfo = ref({}) //员工信息

    const setToken = (tk) => (token.value = tk) // 设置 token
    const removeToken = () => {
      token.value = ''
    }

    const setEmpInfo = (emp) => {
      empInfo.value = emp
    }

    const removeEmpInfo = () => {
      empInfo.value = {}
    }
    return {
      token,
      setToken,
      removeToken,
      empInfo,
      setEmpInfo,
      removeEmpInfo
    }
  },
  {
    persist: true
  }
)
